package com.chzu.controller;

import com.chzu.pojo.SysMenu;
import com.chzu.result.JsonResult;
import com.chzu.result.QueryInfo;
import com.chzu.service.SysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author lz
 * @Version 1.0
 * @Company 滁州大健康与养老产业研究院
 * @ClassName SysMenuController
 * @Description TODO
 * @Date 2022/02/02 22:27
 */
@RestController
@RequestMapping("/menu")
@Api(tags = "菜单接口数据")
public class SysMenuController {

    @Resource
    private SysMenuService menuService;

    @ApiOperation("分页查询菜单信息")
    @PostMapping("/findPage")
    public JsonResult<Object> findMenu(@RequestBody QueryInfo queryInfo) {
        return menuService.findMenu(queryInfo);
    }

    @ApiOperation("添加菜单信息")
    @PostMapping("/insert")
    public JsonResult<Object> insertMenu(@RequestBody SysMenu menu) {
        return menuService.insertMenu(menu);
    }

    @ApiOperation("修改菜单信息")
    @PutMapping("/update")
    public JsonResult<Object> updateMenu(@RequestBody SysMenu menu) {
        return menuService.updateMenu(menu);
    }

    @ApiOperation("删除菜单信息")
    @DeleteMapping("/delete/{id}")
    public JsonResult<Object> deleteMenu(@PathVariable("id") Integer id) {
        return menuService.deleteMenu(id);
    }

    @ApiOperation("查询所有父级菜单信息")
    @GetMapping("/findParent")
    public JsonResult<Object> findParent() {
        return menuService.findParent();
    }

}
